<template>
  <header class="header">
    <div class="container">
      <nav class="navbar">
        <div class="logo">
          <h1>科技公司</h1>
        </div>
        <ul class="nav-links" :class="{ 'mobile-menu-active': isMobileMenuOpen }">
          <li><router-link to="/" class="nav-link" @click="closeMenu">首页</router-link></li>
          <li><router-link to="/product" class="nav-link" @click="closeMenu">产品介绍</router-link></li>
          <li><router-link to="/about" class="nav-link" @click="closeMenu">关于我们</router-link></li>
          <li><router-link to="/contact" class="nav-link" @click="closeMenu">联系我们</router-link></li>
        </ul>
        <div class="mobile-menu-toggle" @click="toggleMobileMenu">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </nav>
    </div>
  </header>
</template>

<script>
export default {
  name: 'Header',
  data() {
    return {
      isMobileMenuOpen: false
    }
  },
  methods: {
    toggleMobileMenu() {
      this.isMobileMenuOpen = !this.isMobileMenuOpen
    },
    closeMenu() {
      this.isMobileMenuOpen = false
    }
  }
}
</script>

<style scoped>
.header {
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
}

.logo h1 {
  color: #007bff;
  font-size: 1.8rem;
  margin: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 30px;
}

.nav-link {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-link:hover,
.nav-link.router-link-active {
  color: #007bff;
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 4px;
}

.mobile-menu-toggle span {
  width: 25px;
  height: 3px;
  background-color: #333;
  transition: 0.3s;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  .nav-links {
    position: fixed;
    top: 80px;
    left: -100%;
    width: 100%;
    height: calc(100vh - 80px);
    background-color: white;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 40px;
    transition: left 0.3s ease-in-out;
    gap: 20px;
  }
  
  .nav-links.mobile-menu-active {
    left: 0;
  }
}
</style>
